﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AutoTestEntry.SpecificUtility;

namespace AutoTestEntry.UI
{
	public partial class SVNLoginForm : Form
	{
		private EnvDepoly envDeploy;

		public SVNLoginForm()
		{
			InitializeComponent();

			Init();
		}

		private void Init()
		{
			this.StartPosition = FormStartPosition.CenterScreen;
			this.FormBorderStyle = FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;

            txtPasswd.KeyUp += txtPasswd_KeyUp;
			btnLogin.Click += btnLogin_Click;
			btnCancel.Click += btnCancel_Click;

			envDeploy = new EnvDepoly();
		}

        private void txtPasswd_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnLogin_Click(this, null);
            }
        }

		private void btnLogin_Click(Object sender, EventArgs e)
		{
			if (txtUserName.Text == "" || txtPasswd.Text == "")
			{
				MessageBox.Show("请填写完整");
			}
			else
			{
				envDeploy.SetSvnUserNameAndPasswd(txtUserName.Text, txtPasswd.Text);
				this.DialogResult = DialogResult.Yes;
				this.Dispose();
			}
		}

		private void btnCancel_Click(Object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
			this.Dispose();
		}
	}
}
